<?php


class Apiuser extends ApiBase {

	private $user_id;
	public function __construct(){
		parent::__construct();
		$this->user_id=$this->GetUser()['user_id'];
	}

	public function index(){
      $where['user_id']=$this->user_id;
	  $list=$this->db->select('gender,name,nickName,email,phone,province,city,region,address')->where($where)->get('user')->row_array();
	  $this->show($list);
	}

	public function update(){
	  $where['user_id']=$this->user_id;
      $post=$this->input->post();
      unset($post['token']);
      $res=$this->db->where($where)->update('user',$post);
      if ($res){
      	$this->show(array('code'=>1,'msg'=>'更新成功'));
	  }else{
		$this->show(array('code'=>0,'msg'=>'更新失败'));
	  }
	}

}
